<div id="entry-new">

  <div id="ledger-error">
    <%= error_messages_for :entry %>
  </div>

  <% form_remote_for :entry, Entry.new,
       :html => {:id => 'entry-form'},
       :url => hash_for_entry_url(:account => @account, :action => 'new') ,
       :loading => "App.disableForm('entry-form')",
       :complete => "App.enableForm('entry-form')" do |f| %>
    <table>
      <tr>
        <td><%= f.date_select :transaction_date, :order => [:day, :month, :year] %></td>
        <td>
          <%= text_field_with_auto_complete :entry, :payee_name, {:style => 'width:400px;'}, {
                :url => hash_for_entry_url(:account => @account, :action => 'auto_complete_payee'),
                :after_update_element => "Ledger.afterPayeeUpdate",
                :select => "payee-name"} %>

          <%= f.hidden_field :payee_id %>
          <br />


          <%= f.select(:category_id, nested_set_options_for_select2(@user.categories) { |cat|
              cat.level > 0 ? "#{("-"*2)} #{cat.full_name}" : cat.full_name
            }, {}, {:class => 'category-behavior categories'}) %>
          <em><%= f.text_field 'memo', :class => 'memo' %></em>
        </td>
        <td><%= f.text_field 'debit', :class => 'money-behavior numeric debit' %></td>
        <td><%= f.text_field 'credit', :class => 'money-behavior numeric credit' %></td>
        <td>
          <%= submit_tag 'Add' %>
          <%= image_tag 'indicator.gif', :id => 'activity-indicator', :style => 'display:none;'%>
        </td>
      </tr>
    </table>
  <% end  %>

</div>

<script>
  Form.enable('entry-form');
  Money.applyBehavior($('entry-new'));
</script>

